<?php
namespace Home\Controller;
use Think\Controller;
class ProductController extends Controller {
    public function index(){
    	$this->sort=M('sort')->order('id')->select();
        $this->display();
    }
    //产品详情页
    public function product_info(){
      $this->sort=M('sort')->order('id')->select();
    	$id = I('id');
    	$p=M('product')->where("id='$id'")->find();
      $this->parentid = $p['parentid'];
      $this->assign('p',$p);
    	$this->display();
    }
   	//根据parentid获取产品
   	public function get_product(){
   		$id = I('id');
   		$p = M('product')->where("parentid='$id'")->select();
   		if($p == array()){
   			$this->ajaxReturn(V(2,'未获取到数据'));
   			exit;
   		}
      $this->assign('p',$p);
   		$this->display('product_list');
   	}
}